<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 15c
  Date: 2017/6/7
  Time: 18:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
</head>
<body>
<jsp:include page="head.jsp"/>
<%--<h1 style="text-align: center">欢迎来到学生系统</h1>--%>
<%--欢迎管理员:<span style="color: brown"><%=uname%> </span> <span id="today"></span>--%>
<br>

<div style="width:100%;height: auto;text-align: center;margin-top: 3%">
    <table border="5" cellpadding="4" cellspacing="3" align="center">
        <thead>
        <tr>
            <th>课程号</th>
            <th>课程名</th>
            <th>学分</th>
            <th>执行操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${courseList}" var="course">
            <tr>
                <td>${course.cno}</td>
                <td>${course.cname}</td>
                <td>${course.ccredit} </td>
                <td>
                    <div style="margin-left: 3px;background-color:#1648aa;float: left ;cursor:pointer;text-align: center;width: 80%">
                        <a
                                href="${pageContext.request.contextPath}/students/course_update?cno=${course.cno}"
                                style="font-size: 14px;color: #fff">更新</a></div>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<script>
//    课程信息更新
var type = "<%=session.getAttribute("course_update-type")%>";
if (type == "ok") {
(function foo() {
alert("修改成功");
<%session.removeAttribute("course_update-type");%>
})
();
} else if (type == "error") {
(function foo() {
alert("修改失败");
<%session.removeAttribute("course_update-type");%>
})
();
}
//    课程添加
var course_add_type = "<%=session.getAttribute("course_add-type")%>";
if (course_add_type == "ok") {
    (function foo() {
        alert("添加成功");
        <%session.removeAttribute("course_add-type");%>
    })
    ();
} else if (course_add_type == "error") {
    (function foo() {
        alert("添加失败");
        <%session.removeAttribute("course_add-type");%>
    })
    ();
}

</script>
</body>
</html>
